package com.wesley.singleton;


/**
 * <h1>枚举方式</h1>
 * <p>
 * 枚举默认就是单例的
 * </p>
 */
public class SingletonTest6 {

    // 测试方法
    public static void main(String[] args) {
        for (int i = 0; i < 5; i++) {
            new Thread(() -> {
                Singleton instance = Singleton.INSTANCE;
                System.out.println(Thread.currentThread().getName() + "---instance.hashCode():" + instance.hashCode());
            }).start();

        }
    }
}


enum Singleton {
    INSTANCE;

    public void hello() {
        System.out.println("hello");
    }
}
